<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑</title>


<link rel="stylesheet"
	href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	function validate() {

		//alert("haha");
		var quantity = $("#valiprice").val();
		var price = $("#valiquantity").val();

		//alert(quantity);
		var reg = new RegExp("^\\d{1,5}");
		var flag1 = reg.test(price);
		var flag2 = reg.test(quantity);
		if (flag1 == false) {
			return false;
		}
		if (flag2 == false) {

			return false;
		}

		return false;

	}
	$(function() {

		$("#valiprice").blur(function() {

			var price = $(this).val();
			var reg = new RegExp("^\\d{1,5}");
			var flag = reg.test(price);
			if (flag == true) {
				$("#price").html("成功").css("color", "green");
				if (quantity < 0) {

					$("#price").html("数量不能为负").css("color", "red");
				}
			} else {

				$("#price").html("必须为数字").css("color", "red");
			}
		});
		$("#valiquantity").blur(function() {

			var quantity = $(this).val();
			var reg = new RegExp("^\\d{1,5}");
			var flag = reg.test(quantity);
			if (flag == true) {
				$("#quantity").html("成功").css("color", "green");
				if (quantity < 0) {

					$("#quantity").html("数量不能为负").css("color", "red");
				}
			} else {

				$("#quantity").html("必须为数字").css("color", "red");
			}

		});
	});
</script>
</head>
<body>
	<div class="container">
		<div class="jumbotron well">
			<h3></h3>
			<p>系统后台</p>
		</div>
		<ul class="breadcrumb">
			<li><a href="#">在线商场购物系统</a></li>
			<li><a href="#">商品管理</a></li>
			<li class="active">商品信息修改</li>
		</ul>

		<form action="/goods/edit" method="post" class="form-horizontal"
			role="form">


			<div class="form-group">
				<input type="hidden" name="zybgoodid" value="${good.zybgoodid }" />
				<label for="lastname" class="col-sm-2 control-label">商品名称：</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="zybgoodname"
						value="${good.zybgoodname }">
				</div>
			</div>
			<div class="form-group">
				<label for="firstname" class="col-sm-2 control-label">商品单价</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" value="${good.zybprice }"
						name="zybprice" id="valiprice">
					<div id="price"></div>
				</div>
			</div>
			<div class="form-group">
				<label for="lastname" class="col-sm-2 control-label">商品数量</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="zybquantity"
						value="${good.zybquantity }" id="valiquantity">
					<div id="quantity"></div>
				</div>
			</div>

			<div class="form-group">
				<label for="lastname" class="col-sm-2 control-label">商品简介</label>
				<div class="col-sm-10">
					<textarea maxlength="100" class="form-control" name="zybgooddesc">${good.zybgooddesc }</textarea>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="submit" class="btn btn-primary" value="修改"
						onclick="return validate();"> <a
						href="/goods/adminpagelist" class="btn btn-danger">取消</a>
				</div>
			</div>
		</form>
	</div>
</body>
</html>